﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Data;
using Volo.Abp.Domain.Entities;
using Volo.Abp.MultiTenancy;
using Volo.Abp;

namespace Himp.TaskScheduling
{
    /// <summary>
    /// 业务流节点
    /// </summary>
    public class BizflowNode : Entity<Guid>, IMultiTenant, ISoftDelete, IHasExtraProperties
    {
        /// <summary>
        /// 
        /// </summary>
        public Guid BizflowConfigId { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public BizflowConfig BizflowConfig { get; set; }

        /// <summary>
        /// 工作流节点Key
        /// </summary>
        public string WorkflowNodeKey { get; set; }

        /// <summary>
        /// 工作流节点名称
        /// </summary>
        public string WorkflowNodeName { get; set; }

        /// <summary>
        /// 流程节点类别
        /// </summary>
        public EnumBizflowNodeType WorkflowNodeType { get; set; }

        /// <summary>
        /// 节点序号
        /// </summary>
        public int WorkflowIndex { get; set; }

        /// <summary>
        /// schema
        /// </summary>
        public string? SchemaUI { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public string? AssigneeParName { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public string? CaudidateUsersParName { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public string? CaudidateGroupsParName { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public string[] AssigneeDefValues { get; set; }

        /// <summary>
        /// 候选用户
        /// </summary>
        public string[] CandidateUsersDefValues { get; set; }

        /// <summary>
        /// 候选组
        /// </summary>
        public string[] CandidateGroupsDefValues { get; set; }

        /// <summary>
        /// 组件
        /// </summary>
        public string? Component { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public bool ValiFlag { get; set; }

        /// <summary>
        /// 可审核
        /// </summary>
        public bool CanAuditFlag { get; set; }

        /// <summary>
        /// 可驳回
        /// </summary>
        public bool CanRejectFlag { get; set; }

        /// <summary>
        /// 可编辑
        /// </summary>
        public bool CanEditFlag { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public Guid? TenantId { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public bool IsDeleted { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public ExtraPropertyDictionary ExtraProperties { get; set; }

        /// <summary>
        /// 业务流程关联候选人列表
        /// </summary>
        public List<BizflowNodeAssocCandidateUser> BizflowNodeAssocCandidateUsers { get; set; }

        public BizflowNode()
        {
            ExtraProperties = new ExtraPropertyDictionary();
        }

        public BizflowNode(Guid workflowTypeId, string workflowModelId, string processNodeName, EnumBizflowNodeType workflowNodeType)
        {
            //WorkflowAssocBizflowId = workflowTypeId;
            WorkflowNodeType = workflowNodeType;
            //SchemaUI = schema;
            ExtraProperties = new ExtraPropertyDictionary();
        }
    }

    ///// <summary>
    ///// 
    ///// </summary>
    //public static class WorkflowNodeExtensions
    //{
    //    private const string SFSchema = "SFSchema";

    //    public static void SetStColumns(this BizflowNode item, List<WorkflowNodeSFSchema> pars)
    //    {
    //        item.SetProperty(SFSchema, pars);
    //    }

    //    public static List<WorkflowNodeSFSchema> GetStColumns(this BizflowNode item)
    //    {
    //        return item.Property<List<WorkflowNodeSFSchema>>(SFSchema);
    //    }
    //}

    public class WorkflowNodeSFSchema
    {
        public string PropertyName { get; set; }

        public string Type { get; set; }

        public string Title { get; set; }

        public string? Format { get; set; }

        public int? MaxLength { get; set; }

        public int? MinLength { get; set; }
    }
}
